public class Practice3 {
    /*
    链接https://leetcode.cn/problems/XltzEq/description/
    主要是注意审题, 使用StringBuilder比ArrayList<>()要更快一些
    不用考虑长度的奇偶性
     */
    public boolean isPalindrome(String s) {
        StringBuilder q = new StringBuilder();
        int n = s.length();
        for(int i = 0;i < n;i++){
            char ch = s.charAt(i);
            if((ch >= 'a' && ch <= 'z')){
                q.append(ch);
            }else if((ch >= 'A' && ch <= 'Z')){
                q.append((char)(32 + ch));
            }else if((ch >= '0' && ch <= '9')){
                q.append(ch);
            }
        }
        int left = 0;
        int right = q.length() - 1;
        while(left < right){
            if(q.charAt(left++) != q.charAt(right--)){
                return false;
            }
        }
        return true;
    }
}
